package it.rikesh.aip2011.shared.model;

import java.io.Serializable;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.Text;

import org.slim3.datastore.Attribute;
import org.slim3.datastore.InverseModelListRef;
import org.slim3.datastore.InverseModelRef;
import org.slim3.datastore.Model;

@Model(schemaVersion = 1)
public class Trail implements Serializable {

    private static final long serialVersionUID = 1L;

    @Attribute(primaryKey = true)
    private Key key;

    @Attribute(version = true)
    private Long version;
    
    @Attribute(persistent = true)
    private String name;
    
    @Attribute(persistent = true)
    private Text dDescription;
    
    @Attribute(persistent = true)
    private String link;
    
    @Attribute(persistent = true)
    private String activity;
    
    @Attribute(persistent = false)
    private InverseModelListRef<HutTrail, Trail> hutTrailListRef = 
        new  InverseModelListRef<HutTrail, Trail>(HutTrail.class,  "trailRef", this);
    
    @Attribute(persistent = false)
    private InverseModelListRef<TrailFaunaFlora, Trail> trailFaunaFloraListRef = 
        new  InverseModelListRef<TrailFaunaFlora, Trail>(TrailFaunaFlora.class,  "trailRef", this);

    @Attribute(persistent = false)
    private InverseModelRef<Activity, Trail> activityRef = new InverseModelRef<Activity, Trail>(Activity.class, "trailRef", this);
    
    /**
     * Returns the key.
     *
     * @return the key
     */
    public Key getKey() {
        return key;
    }

    /**
     * Sets the key.
     *
     * @param key
     *            the key
     */
    public void setKey(Key key) {
        this.key = key;
    }

    /**
     * Returns the version.
     *
     * @return the version
     */
    public Long getVersion() {
        return version;
    }

    /**
     * Sets the version.
     *
     * @param version
     *            the version
     */
    public void setVersion(Long version) {
        this.version = version;
    }

    
    
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Text getDDescription() {
        return dDescription;
    }

    public void setDDescription(Text dDescription) {
        this.dDescription = dDescription;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((key == null) ? 0 : key.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        Trail other = (Trail) obj;
        if (key == null) {
            if (other.key != null) {
                return false;
            }
        } else if (!key.equals(other.key)) {
            return false;
        }
        return true;
    }

    public InverseModelListRef<HutTrail, Trail> getHutTrailListRef() {
        return hutTrailListRef;
    }

    public InverseModelListRef<TrailFaunaFlora, Trail> getTrailFaunaFloraListRef() {
        return trailFaunaFloraListRef;
    }

    public InverseModelRef<Activity, Trail> getActivityRef() {
        return activityRef;
    }

    public void setActivity(String activity) {
        this.activity = activity;
    }

    public String getActivity() {
        return activity;
    }

    public void setLink(String link) {
        this.link = link;
    }

    public String getLink() {
        return link;
    }
}
